package com.itheima.JDBC;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class JDBCDemo02 {
    public static void main(String[] args) throws Exception {
     //1. 注册驱动
     Class.forName("com.mysql.jdbc.Driver");
     //2. 获取连接
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/db1", "root", "root");
        //3. 获取语句执行体对象
        Statement st = conn.createStatement();
        //4. 编写sql
        String sql = "UPDATE user SET age=age+1 where name='lucy'";
        //5. 执行sql
        int i = st.executeUpdate(sql);
        System.out.println("i = " + i);
        //6. 释放资源
        st.close();
        conn.close();
    }
}
